using System;
using System.Collections;
using System.Web;

namespace app.scrum
{
    public partial class VirtualWall : ScrumPage
    {

        public VirtualWall()
        {
            this.sObject.tableName = "backlog";
        }

        public override void read(HttpContext context)
        {            
            this.sObject.readCmdText = "select b.* from backlog b, sprint s"
                    + " where b.sprint = s.id__c";
            try
            {
                ArrayList sObjList = this.sObject.read();
                ArrayList statusList = Constant.Status.values;
                string statusCandidateValues = JsonHelper.stringList2Array(statusList);
                ScrumObjectHelper.assignCandidateValues(sObjList, "status", statusCandidateValues);
                ArrayList userList = this.sObject.getScrumObjectSimpleList("user");
                string userJson = JsonHelper.getJson(userList);
                string userJsonRecPart = JsonHelper.getJsonRecordPartFromJson(userJson);
                string userCandiateValues = JsonHelper.jsonRecPart2Array(userJsonRecPart);
                ScrumObjectHelper.assignCandidateValues(sObjList, "assignee", userCandiateValues);
                ScrumObjectHelper.assignDisplay(sObjList, "assignee", userList);
                ScrumObjectHelper.assignLookup(this.sObject, sObjList, "team");
                string json = JsonHelper.getJson(sObjList);
                context.Response.Write(json);
            }
            catch (Exception ex)
            {
                this.handleException(context.Response, ex);
            }
        }
    }
}